package com.load.batch;

import com.web.web.SessionAction;


public class BatchExecutor extends SessionAction {

	private static final long serialVersionUID = 1L;

	private String status;

	private float successLoaded;

	private int errorsLoaded;

	private float totalLoad;

	private float progress;

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public float getSuccessLoaded() {
		return successLoaded;
	}

	public int getErrorsLoaded() {
		return errorsLoaded;
	}

	public float getTotalLoad() {
		return totalLoad;
	}

	public void setTotalLoad(float totalLoad) {
		this.totalLoad = totalLoad;
	}

	public int getTotalLoadInteger() {
		return (int) totalLoad;
	}

	public String getProgressString() {
		int progressInteger = (int) (progress * 100);
		return progressInteger + "%";
	}

	public float getProgress() {
		return progress;
	}

	public void addSuccessLoaded(String status) {
		successLoaded++;
		setStatus(status);
		updateProgress();
	}

	public void addErrorsLoaded(String status) {
		errorsLoaded++;
		setStatus(status);
	}

	private void updateProgress() {
		progress = successLoaded / totalLoad;
	}

}
